package project.teg.views;

import project.teg.R;
import project.teg.configuration.Global;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;

public class Options extends PreferenceActivity implements
		OnPreferenceClickListener {

	public final static String GLOBAL = "global";
	public final static String PINCH = "pinch";
	public final static String GESTURES = "gestures";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.options);
		setTitle("Options");
		Global.GetAllValues(this);

		Preference cbp = (Preference) findPreference(GLOBAL);
		cbp.setOnPreferenceClickListener(this);

		cbp = (Preference) findPreference(GESTURES);
		cbp.setOnPreferenceClickListener(this);

		cbp = (Preference) findPreference(PINCH);
		cbp.setOnPreferenceClickListener(this);
	}

	@Override
	public boolean onPreferenceClick(Preference arg0) {

		if (arg0 instanceof Preference) {
			Preference cbp = (Preference) arg0;
			if (cbp.getKey().equals(GLOBAL)) {
				Intent intent = new Intent(this, OptionsGlobal.class);
				startActivity(intent);
			} else if (cbp.getKey().equals(GESTURES)) {
				Intent intent = new Intent(this, OptionsGestures.class);
				startActivity(intent);
			} else if (cbp.getKey().equals(PINCH)) {
				Intent intent = new Intent(this, OptionsPinch.class);
				startActivity(intent);
			}
		}
		return false;
	}
}
